<?php 

	//	die("hello world");
	//	echo MAIN_URL;die();
	//	echo javascript:_request();die();
?>
<!--javascript:_request();-->
<?php 
	//	call function by calling javascript
	//	echo _UserMenu();die();
?>

<div id="header">
	<div class="wauto">
		<div class="headerLink">
		<ul>
            <li class="xemphim"><a href="<?=MAIN_URL?>" title="xem phim online, phim bmt, xem phim nhanh, phim hd online">Xem phim</a></li>
			<li class="hotro"><a rel="nofollow" href="javascript:_request();" title="Yêu cầu hỗ trợ">Hỗ trợ</a></li>
			<li class="headerInfo">
            	<?=_UserMenu();?>
            </li>
        </ul>
		</div>
    	<div class="headerTop">
        	<a class="logo" href="./">Xem phim online</a>
			<div class="searchBox">
                <div class="searchBoxLeft">
                    <div class="searchBoxRight">
                    <form method="post" onsubmit="return do_search();">
                    <input type="text" value="Từ khóa" x-webkit-speech="" onfocus="if(this.value=='Từ khóa')this.value=''" onblur="if(this.value=='')this.value='Từ khóa'" id="searchInput" name="query" onkeydown="EnterKey(event);" class="inputSearch">
                    <input type="button" value="" class="btnsearch">
                    </form>
                    </div>
            	</div>
            </div>
        </div>
        
		<br class="clr">
        <div class="headerBottom">
			<div class="category_">
			<!--			it means??			-->
            	<div class="title<?php if(in_array($value[0], array('index','home','trang-chu',''))) echo ' active';?>"><a href="<?=MAIN_URL?>">Trang chủ</a></div>
			</div>
        	<div class="category_">
            	<div class="title<?php if($value[0] == 'the-loai') echo ' active';?>">Thể loại</div>
                <ul>
					<?php
                    // tao cache
                    $file 				= 	CACHE."/the-loai.ipos";
                    $expire 			= 	86400; // 24h
                    if (file_exists($file) &&
                        filemtime($file) > (time() - $expire)) {
                        include($file);
                    } else {
                        $category	=	$db->database("danhmucid,danhmucten","category","danhmucid != 0 ORDER BY danhmucstt ASC");
                        
                        //echo "hoang";die();
                        
                        for($i=0;$i<count($category);$i++) {	
                            $url_category	=	url_link($category[$i][1],0,'the-loai');
                            $html			.= "<li><a title=\"".$category[$i][1]."\" href=\"$url_category\">".$category[$i][1]."</a></li>";
                        }
                        // lưu cache
                        $fp = fopen($file,"w");
                        fputs($fp, $html);
                        fclose($fp);
                        include($file);
                    }
                    ?>
                </ul>
            </div>
			<div class="category_">
            	<div class="title<?php if($value[0] == 'quoc-gia') echo ' active';?>">Quốc gia</div>
                <ul>
					<?php
                    // tao cache
                    $file 				= 	CACHE."/quoc-gia.ipos";
                    $expire 			= 	86400; // 24h
                    if (file_exists($file) &&
                        filemtime($file) > (time() - $expire)) {
                        include($file);
                    } else {
                        $country	=	$db->database("quocgiaid,quocgiaten","country","quocgiaid != 0 ORDER BY quocgiastt ASC");
                        for($i=0;$i<count($country);$i++) {	
                            $url_country	=	url_link($country[$i][1],0,'quoc-gia');
                            $html2			.= "<li><a title=\"".$country[$i][1]."\" href=\"$url_country\">".$country[$i][1]."</a></li>";
                        }
                        // lưu cache
                        $fp = fopen($file,"w");
                        fputs($fp, $html2);
                        fclose($fp);
                        include($file);
                    }
                    ?>
                </ul>
            </div>
			<div class="category_">
            	<div class="title<?php if($value[1] == 'phim-bo') echo ' active';?>"><a href="<?=MAIN_URL?>/danh-sach/phim-bo.html">Phim bộ</a></div>
				<ul>
				<li><a href="danh-sach/phim-bo.html?year=2013">2013</a></li>
				<li><a href="danh-sach/phim-bo.html?year=2012">2012</a></li>
				<li><a href="danh-sach/phim-bo.html?year=2011">2011</a></li>
				<li><a href="danh-sach/phim-bo.html?year=2010">2010</a></li>
				<li><a href="danh-sach/phim-bo.html?year=2009">2009</a></li>
				<li><a href="danh-sach/phim-bo.html?year=2008">2008</a></li>
				</ul>
			</div>
			<div class="category_">
            	<div class="title<?php if($value[1] == 'phim-le') echo ' active';?>"><a href="<?=MAIN_URL?>/danh-sach/phim-le.html">Phim lẻ</a></div>
				<ul>
				<li><a href="danh-sach/phim-le.html?year=2013">2013</a></li>
				<li><a href="danh-sach/phim-le.html?year=2012">2012</a></li>
				<li><a href="danh-sach/phim-le.html?year=2011">2011</a></li>
				<li><a href="danh-sach/phim-le.html?year=2010">2010</a></li>
				<li><a href="danh-sach/phim-le.html?year=2009">2009</a></li>
				<li><a href="danh-sach/phim-le.html?year=2008">2008</a></li>
				</ul>
			</div>
			<div class="category_">
            	<div class="title<?php if($value[1] == 'phim-moi') echo ' active';?>"><a href="<?=MAIN_URL?>/danh-sach/phim-moi.html">Phim mới</a></div>
				<ul>
				<li><a href="danh-sach/phim-moi.html?year=2013">2013</a></li>
				<li><a href="danh-sach/phim-moi.html?year=2012">2012</a></li>
				<li><a href="danh-sach/phim-moi.html?year=2011">2011</a></li>
				<li><a href="danh-sach/phim-moi.html?year=2010">2010</a></li>
				<li><a href="danh-sach/phim-moi.html?year=2009">2009</a></li>
				<li><a href="danh-sach/phim-moi.html?year=2008">2008</a></li>
				</ul>
			</div>
			<div class="category_">
            	<div class="title<?php if($value[0] == 'bang-xep-hang') echo ' active';?>"><a href="<?=MAIN_URL?>/bang-xep-hang.html">Xếp hạng</a></div>
			</div>
		
				<?php if($_SESSION["ipos_userid"]) {
				$user	=	$db->database("username","user","userid = '".$_SESSION["ipos_userid"]."'");
				echo '<div class="category_ hopphim"><div class="title">Hộp Phim</div><ul>';?>
				<?php
		$userid 	= 	$_SESSION["ipos_userid"];
		$listlike	=	get_data("like","phimlike","userid = '$userid'");
			for($i=0;$i<count($arr);$i++) {
		$arr		=	$db->database("phimid,tenphim","film","phimid IN ($listlike)");
				$number	=	$i+1;
				$phimidfav		=	$arr[$i][0];
				$tenphimfav	=	$arr[$i][1];
				$urlphimfav 	=	url_link($tenphimfav,$phimidfav,'phim');
				echo "<li><a title=\"".$tenphimfav."\" href=\"$urlphimfav\">".cut($tenphimfav,25)."</a></li><li>";
			}
?>
		

				<? echo '</ul></div>'; }?>
       
	</div>
</div>
<!-- end header -->